<?php
defined('IN_MAIN') or exit('Invalid Access!');

function get_total_group_downline($uid, $date_from='', $date_to=''){
global $vars;
$db=$vars['db'];

$total_downline=0;
$upline=$uid;
if($upline){	if($date_from && $date_to){		$total_downline = @mysql_result(mysql_query("select count(a.id) from $db->users a inner join $db->users b on b.matrix_left>a.matrix_left and b.matrix_right<=a.matrix_right and b.cdate>='$date_from' and b.cdate<='$date_to' where a.id=$upline"), 0);	}else{		$total_downline = @mysql_result(mysql_query("select count(a.id) from $db->users a inner join $db->users b on b.matrix_left>a.matrix_left and b.matrix_right<=a.matrix_right where a.id=$upline"), 0);	}		if(!$total_downline){		$total_downline = 0;	}	
}
return $total_downline;
}
?>